
Page({
    data: {
        windowHeight:0,//屏幕高度
        statusBarHeight: 0,//状态栏
        navBarHeight: 0,//导航栏
        statusBarHeightmargintop: 0,//胶囊上边距
        safeHeight: 0,//安全区域，内容区域 + 导航栏
        bottomSafeHeight: 0,

        //元素宽高
        listHeight:0,//滚动区域高度
        
        //tab切换
        currentTab: 0,

        //弹窗
        showpopshare: false ,
        showpophuodongguize: false ,

      },
      //获取元素宽高
      getRect: function () {
        var _this = this;
        setTimeout(() => {
            const windowInfo = wx.getWindowInfo();
            wx.createSelectorQuery().selectAll('.header,.mem_share_tit,.mem_share_info,.mem_share_list .tab_nav,.foot_tabbar').boundingClientRect().exec(function(res){
                _this.setData({
                    listHeight: windowInfo.screenHeight-res[0][0].height-res[0][1].height-res[0][2].height-res[0][3].height-res[0][4].height,
                });
              });
          }, 300);
        
      },
      //tab切换
      clickTab: function (e) {
        var that = this;
        if (this.data.currentTab === e.target.dataset.current) {
          return false;
        } else {
          that.setData({
            currentTab: e.target.dataset.current
          })
        }
      },
      onLoad() {
        // 获取系统顶部数值
        const windowInfo = wx.getWindowInfo();
        const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
        let windowHeight = windowInfo.screenHeight;
        let statusBarHeight = windowInfo.statusBarHeight;
        let navBarHeight =
          menuButtonInfo.height + (menuButtonInfo.top - statusBarHeight) * 2;
        let statusBarHeightmargintop =
          menuButtonInfo.top - statusBarHeight;
        let safeHeight = windowInfo.safeArea.height;
        let bottomSafeHeight =
          windowInfo.screenHeight - windowInfo.safeArea.height - statusBarHeight;
        this.setData({
          windowHeight,
          statusBarHeight,
          navBarHeight,
          statusBarHeightmargintop,
          safeHeight,
          bottomSafeHeight,
        });

        //调用 计算高度 的方法
        this.getRect();

      },
    // 弹窗，分享
    showpopshare() {
        this.setData({ showpopshare: true });
    },
    hidepopshare() {
        this.setData({ showpopshare: false });
    },
    // 弹窗，活动规则
    showpophuodongguize() {
        this.setData({ showpophuodongguize: true });
    },
    hidepophuodongguize() {
        this.setData({ showpophuodongguize: false });
    },

})
